
// // ‌在JavaScript中，将字符串转换成UTF-8编码的主要方法是通过TextEncoder
// const encoder = new TextEncoder();
// const text = "UCf0Rhq7VFqgx1DN";
// const bytes = encoder.encode(text);
// console.log(bytes);
//
// //在JavaScript中，将UTF-8编码换成字符串转的主要方法是通过TextEncoder
// console.log(new TextDecoder().decode(bytes));





//Base64 编码和解码的使用方法；下载库： npm install --save js-base64
var base64 = require('js-base64').Base64;
//1.加密
var str = 'ms46pd/IFZ6X0v34Fzw8QaV6va++ilVybnwjDYfFgsHtF9O4CnQSjUwnptV1O8TU9nfUAx0FtUfvVT87TAwvUdcIiilp6jfLQvEREEbsRDXHXaQRDwUuBFfzTZ1ltyNZXUa8msdyXcshGTgQ96UnYg==';
// // var base = new Base64();
// var result = base64.encode(str);
// console.log(result)
// //2.解密
// var result2 = base64.decode(result);
// console.log(result2)

// var result2 = base64.decode(str);
// console.log(result2)

// window = global;
// //编码，输出："MTIzNDU2"
// window.btoa("123456");
// //解码，输出：123456
// window.atob("MTIzNDU2");



// const b64string = 'SGVsbG8gV29ybGQ='; // 示例 base-64 编码字符串
const b64string = 'ms46pd/IFZ6X0v34Fzw8QeEFdYI7uA0rwWDdKk4f3Np3vPXrWU+mewm6IiBf1tgasualurPb8v/ZMwW1WjiTrCbrrVXZ/0sqThyNa14tQglU0MIgADgVVlS3xvhpPrzYtR5XrK2cKk6gD25UMXTN1PI3wIVA/LgPeZMuY63TtLPtO91Q9+KL49f45QPVPuGnK7ZKcPqmpQV8bTBDza5outcIiilp6jfLQvEREEbsRDXHXaQRDwUuBFfzTZ1ltyNZXUa8msdyXcshGTgQ96UnYg=='; // 示例 base-64 编码字符串

// 使用 Buffer 解码 base-64 编码的字符串
const buffer = Buffer.from(b64string, 'base64');
const decodedString = buffer.toString('utf8');

console.log(decodedString); // 输出: Hello World
